package core.utils.communicationTester;

import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;

import org.jboss.remoting.InvokerLocator;

public class Client {
	private org.jboss.remoting.Client client = null;
	
	public Client(String locatorURI) {
		try {
			InvokerLocator invokerLocator;
			invokerLocator = new InvokerLocator("socket://" + locatorURI);
			client = new org.jboss.remoting.Client(invokerLocator, locatorURI);
			client.connect();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void send(Message message) throws Throwable {
		Map<String, String> metadata = new HashMap<String, String>();
		metadata.put("timeout", "5000");
		this.client.invoke(message, metadata);
	}
}
